package com.itheima.Interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class Webcomfig implements WebMvcConfigurer {
    //SpringIOC注解
@Autowired
private DemoInterceptor demoInterceptor;


private LoginIntercepter loginIntercepter;
/*
* 路径详解：
*       addPathInterceptor指的就是拦截所有路径
*       excludePathPatterns指的就是除了某一路径下不拦截（除了login路径不拦截，其它全部拦截）
* 路径写法：
* 只拦截以及路径
* 拦截任意级路径
        depts/* ---  只拦截/depts 下的一级路径

        depts/** ---  拦截/depts 下的任意级路径
* */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       /*registry.addInterceptor(demoInterceptor).addPathPatterns("/**").excludePathPatterns("/login");*/

        registry.addInterceptor(loginIntercepter).addPathPatterns("/**").excludePathPatterns("/login");
    }
}
